%%%-------------------------------------------------------------------
%% @doc db app （通过game_app启动，不可独立启动）
%% @end
%%%-------------------------------------------------------------------

-module(db_app).

-behaviour(application).
-include_lib("game_log/include/log.hrl").

-export([start/2, stop/1]).

start(_StartType, _StartArgs) ->
    ConfigModRet = application:get_env(db, game_config_mod),
    case ConfigModRet of
        undefined ->
            ?LOG_ERROR("config_mod undefined in db app env ~n"),
            init:stop(1);
        {ok, ConfigMod} ->
            DBTypeList = application:get_env(db, db_type_list, []),
            db_config:set_config_mod(ConfigMod),
            ?LOG_INFO("============================ DB UPDATE_CHECK START ============================"),
            db_updater:check(DBTypeList),
            ?LOG_INFO("============================ DB UPDATE_CHECK DONE ============================"),
            ?LOG_INFO("============================ DB START ============================"),
            {ok, SupPid} = db_sup:start_link(DBTypeList),
            ?LOG_INFO("============================ DB DONE ============================"),
            {ok, SupPid}
    end.

stop(_State) ->
    ok.

%% internal functions

